﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiGeometryMetafile : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiGeometryMetafile(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiGeometryMetafile_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiGeometryMetafile obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiGeometryMetafile()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiGeometryMetafile(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiGeometryMetafile cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiGeometryMetafile_cast(OdRxObject.getCPtr(pObj));
			OdGiGeometryMetafile result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGeometryMetafile_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGeometryMetafile_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiGeometryMetafile_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiGeometryMetafile createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiGeometryMetafile_createObject();
			OdGiGeometryMetafile result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiGeometryMetafile)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void clear()
		{
			GlobalsPINVOKE.OdGiGeometryMetafile_clear(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void play(OdGiConveyorGeometry pGeom, OdGiConveyorContext pCtx)
		{
			GlobalsPINVOKE.OdGiGeometryMetafile_play(this.swigCPtr, pGeom.GetCPtr(), pCtx.GetCPtr());
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setRecords(OdGiGeometryMetafile.Record pRec)
		{
			GlobalsPINVOKE.OdGiGeometryMetafile_setRecords(this.swigCPtr, OdGiGeometryMetafile.Record.getCPtr(pRec));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isEmpty()
		{
			bool result = GlobalsPINVOKE.OdGiGeometryMetafile_isEmpty(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiGeometryMetafile.Record firstRecord()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGiGeometryMetafile_firstRecord(this.swigCPtr);
			OdGiGeometryMetafile.Record result = (intPtr == IntPtr.Zero) ? null : new OdGiGeometryMetafile.Record(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiGeometryMetafile.Record lastRecord()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGiGeometryMetafile_lastRecord(this.swigCPtr);
			OdGiGeometryMetafile.Record result = (intPtr == IntPtr.Zero) ? null : new OdGiGeometryMetafile.Record(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public class Record : IDisposable
		{
			[EditorBrowsable(EditorBrowsableState.Never)]
			public Record(IntPtr cPtr, bool cMemoryOwn)
			{
				this.swigCMemOwn = cMemoryOwn;
				this.swigCPtr = new HandleRef(this, cPtr);
			}

			[EditorBrowsable(EditorBrowsableState.Never)]
			public static HandleRef getCPtr(OdGiGeometryMetafile.Record obj)
			{
				if (obj != null)
				{
					return obj.swigCPtr;
				}
				return new HandleRef(null, IntPtr.Zero);
			}

			~Record()
			{
				this.Dispose();
			}

			public virtual void Dispose()
			{
				if (this.swigCPtr.Handle != IntPtr.Zero)
				{
					if (this.swigCMemOwn)
					{
						lock (this.locker)
						{
							if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
							{
								this.swigCMemOwn = false;
								GlobalsPINVOKE.delete_OdGiGeometryMetafile_Record(this.swigCPtr);
							}
						}
						this.swigCMemOwn = false;
					}
					this.swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
			}

			public OdGiGeometryMetafile.Record tail()
			{
				IntPtr intPtr = GlobalsPINVOKE.OdGiGeometryMetafile_Record_tail__SWIG_0(this.swigCPtr);
				OdGiGeometryMetafile.Record result = (intPtr == IntPtr.Zero) ? null : new OdGiGeometryMetafile.Record(intPtr, false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}

			public void setTail(OdGiGeometryMetafile.Record pTail)
			{
				GlobalsPINVOKE.OdGiGeometryMetafile_Record_setTail(this.swigCPtr, OdGiGeometryMetafile.Record.getCPtr(pTail));
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}

			public void deleteList()
			{
				GlobalsPINVOKE.OdGiGeometryMetafile_Record_deleteList(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}

			public virtual void play(OdGiConveyorGeometry pGeom, OdGiConveyorContext pCtx)
			{
				GlobalsPINVOKE.OdGiGeometryMetafile_Record_play(this.swigCPtr, pGeom.GetCPtr(), pCtx.GetCPtr());
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}

			private object locker = new object();

			private HandleRef swigCPtr;

			protected bool swigCMemOwn;
		}
	}
}
